﻿using System;
using System.Windows.Forms;
using WeifenLuo.WinFormsUI.Docking;

namespace AddinSample
{
    public partial class Window : DockContent
    {
        private IYnoteHost MyHost { get; set; }
        public Window(IYnoteHost host)
        {
            InitializeComponent();
            MyHost = host;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            MyHost.ActiveEditor.codebox.InsertText("This is from Sample Plugnin");

        }

        private void button2_Click(object sender, EventArgs e)
        {
            using (OpenFileDialog o = new OpenFileDialog())
            {
                o.Filter = "All Files(*.*)|*.*";
                o.ShowDialog();
                if (!string.IsNullOrEmpty(o.FileName))
                    MyHost.OpenFile(o.FileName, 0); // 0 if codepage is nothing
            }
        }

        private void button3_Click(object sender, EventArgs e)
        {
            MyHost.ActiveEditor.codebox.Bookmarks.Add(MyHost.ActiveEditor.codebox.Selection.Start.iLine);
        }
    }
}
